- name: make the app be real
  hosts: os-masters[0]:os-masters-stg[0]
  user: root
  gather_facts: False

  vars_files:
    - /srv/web/infra/ansible/vars/global.yml
    - "/srv/private/ansible/vars.yml"
    - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  roles:
  # The openshift/project role breaks if the project already exists:
  # https://pagure.io/fedora-infrastructure/issue/6404
  - role: openshift/project
    app: waiverdb
    description: waiverdb
    appowners:
    - ralph
    - mjia
    - dcallagh
    - gnaponie
  - role: openshift/object
    app: waiverdb
    template: secret.yml
    objectname: secret.yml
  - role: openshift/secret-file
    app: waiverdb
    secret_name: waiverdb-stg-secret
    key: client_secrets.json
    template: client_secrets.json
  - role: openshift/secret-file
    app: waiverdb
    secret_name: waiverdb-fedmsg-key
    key: fedmsg-waiverdb.key
    privatefile: fedmsg-certs/keys/waiverdb-waiverdb-web-waiverdb.app.os.stg.fedoraproject.org.key
    when: env == "staging"
  - role: openshift/secret-file
    app: waiverdb
    secret_name: waiverdb-fedmsg-crt
    key: fedmsg-waiverdb.crt
    privatefile: fedmsg-certs/keys/waiverdb-waiverdb-web-waiverdb.app.os.stg.fedoraproject.org.crt
    when: env == "staging"
  - role: openshift/secret-file
    app: waiverdb
    secret_name: waiverdb-fedmsg-key
    key: fedmsg-waiverdb.key
    privatefile: fedmsg-certs/keys/waiverdb-waiverdb-web-waiverdb.app.os.fedoraproject.org.key
    when: env != "staging"
  - role: openshift/secret-file
    app: waiverdb
    secret_name: waiverdb-fedmsg-crt
    key: fedmsg-waiverdb.crt
    privatefile: fedmsg-certs/keys/waiverdb-waiverdb-web-waiverdb.app.os.fedoraproject.org.crt
    when: env != "staging"
  - role: openshift/object
    app: waiverdb
    template: imagestream.yml
    objectname: imagestream.yml
  - role: openshift/object
    app: waiverdb
    template: buildconfig.yml
    objectname: buildconfig.yml
  - role: openshift/start-build
    app: waiverdb
    buildname: waiverdb-docker-build
    objectname: waiverdb-docker-build
  - role: openshift/object
    app: waiverdb
    template: configmap.yml
    objectname: configmap.yml
  - role: openshift/object
    app: waiverdb
    file: service.yml
    objectname: service.yml
  - role: openshift/object
    app: waiverdb
    file: route.yml
    objectname: route.yml
  - role: openshift/object
    app: waiverdb
    template: deploymentconfig.yml
    objectname: deploymentconfig.yml
  - role: openshift/rollout
    app: waiverdb
    dcname: waiverdb-web
